﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "商品库存设置";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    List<Dormitory> dormitoryList = ViewBag.Dormitorys;
    List<ProductRepertory> productRepertorys = ViewBag.productRepertorys;
    int type = ViewBag.Type;
    int productid = ViewBag.ProductID;
    int areacode=ViewBag.AreaCode;
}
@section head{
    <style type="text/css">
        .nav .active
        {
            /*background: url(<?php echo $this->img('manage_r2_c13.jpg');?>) no-repeat;*/
            background-color: #F5F5F5;
        }
        .nav .other
        {
            /* background: url(<?php echo $this->img('manage_r2_c14.jpg');?>) no-repeat;*/
            background-color: #E9E9E9;
        }
        h2.nav
        {
            border-bottom: 1px solid #B4C9C6;
            font-size: 13px;
            height: 25px;
            line-height: 25px;
            margin-top: 0px;
            margin-bottom: 0px;
        }
        h2.nav a
        {
            color: #999999;
            display: block;
            float: left;
            height: 24px;
            width: 113px;
            text-align: center;
            margin-right: 1px;
            margin-left: 1px;
            cursor: pointer;
        }
    </style>
     
}
<div id="content-header">
    <h1>
        商品库存设置</h1>
</div>
<div id="breadcrumb">
    <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>首页</a>
    <a href="#" class="tip-bottom">商品管理</a> <a href="/workspace/CollegeAdmin/GeneralProducts"
        class="current">普通商品</a> <a href="#" class="current">库存设置</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-align-justify"></i></span>
                    <h5>
                        库存设置</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="/CollegeAdmin/SetProductRepertory" method="post" class="form-horizontal">
                    <input type="hidden" name="type" value="@type"/>
                    <input type="hidden" name="id" value="@productid"/>
                    <input type="hidden" name="areacode" value="@areacode"/>
                    <input type="hidden" name="productkey" value="@ViewBag.SearchKey" />
                    <table border="0" cellpadding="0" cellspacing="0">
                     <tr><td><div class="control-group" style="vertical-align:middle;"><label class="control-label" style="font-weight:bold;width:150px;padding-top:10px">楼栋名称</label> 
                                                     <div class="controls" style="font-weight:bold"><span style="vertical-align:middle;width:50px;">现有库存</span><span style="vertical-align:middle;padding-left:10px">入库数量</span></div></div></td>
                                                     <td><div class="control-group"  style="font-weight:bold"><label class="control-label" style="font-weight:bold;width:150px;padding-top:10px">楼栋名称</label> 
                                                     <div class="controls" style="font-weight:bold"><span style="vertical-align:middle;width:50px;">现有库存</span><span style="vertical-align:middle;padding-left:10px">入库数量</span></div></div></td>
                                                     <td><div class="control-group" style="font-weight:bold"><label class="control-label" style="font-weight:bold;width:150px;padding-top:10px">楼栋名称</label> 
                                                     <div class="controls" style="font-weight:bold"><span style="vertical-align:middle;width:50px;">现有库存</span><span style="vertical-align:middle;padding-left:10px">入库数量</span></div></div></td></tr>
                        @{
                                string idsStr = "";

                                int i = 0;
                              
                                if (dormitoryList != null && dormitoryList.Any())
                                {
                                    int count = dormitoryList.Count();
                                    foreach (var dormitory in dormitoryList)
                                    {
                                        int remain = 0;
                                        if (productRepertorys != null && productRepertorys.Any())
                                        {
                                            var repertory = (from c in productRepertorys where c.DormitoryId == dormitory.Id select c).FirstOrDefault();
                                            if (repertory != null)
                                            {
                                                remain = repertory.Remain;
                                            }
                                        }
                                        idsStr = idsStr + dormitory.Id.ToString() + ",";
                                        if (i % 3 == 0)
                                        {  
                                                @:<tr>
                                                 
                                                     <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label> 
                                                     <div class="controls"> 
                                                     <input type="text" name="dormitory@(@dormitory.Id)" readonly value="@remain" style="width: 50px" /> <input type="text" value="" name="newremain@(@dormitory.Id)" placeholder="入库数量" style="width: 80px" /> </div> </div>
                                                </td> 
                                                
                                        }
                                        else
                                        {
                                                    <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label> 
                                                     <div class="controls"> 
                                                     <input type="text" name="dormitory@(@dormitory.Id)" readonly  value="@remain" style="width: 50px" /> <input type="text" value="" name="newremain@(@dormitory.Id)" placeholder="入库数量" style="width: 80px" /> </div> </div>
                                                </td> 
                                            
                                        }
                                        if (i % 3 == 2 || (i + 1) == count)
                                        { 
                                                    @:</tr>                                     
                                         }

                                        i++;
                                    }

                                }
                                if (idsStr != "" && idsStr.Length > 0)
                                {
                                    idsStr = idsStr.Substring(0, idsStr.Length - 1);
                                }
                                  
                         }
                         
                    </table>
                    <input type="hidden" name="dormitoryIDs" value="@idsStr" />
                    <div>
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary">
                                保存</button>&nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:history.go(-1);"  style="margin-top:10px">返回</a>
                                    
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail{
<script type="text/javascript">
    $(function () {
        $('#likProduct').addClass('open');
        $('#likProduct').addClass('active');
    });
</script>
